<?php
class Document {
	private $title;
	private $description;
	private $keywords;	
	private $links = array();		
	private $styles = array();
	private $scripts = array();
	private $submenu = array();
	
	private $page_array = array('home', 'sport', 'circle', 'forum', 'activity','movie','gym');
	private $current_page = 'home';
	
	private $page_user_array = array('information', 'contact', 'career', 'education', 'interests', 'avatar', 'password');
	private $current_page_user = 'information';
	
	private $page_business_array = array('information', 'description', 'apply', 'banner', 'card', 'coach', 'coach_video', 'course', 'curriculum', 'event' , 'info_pub' , 'list' , 'picture', 'serve_tag' , 'video');
	private $current_page_business = 'information';

	private $redirect_url = '';
	
	public function setTitle($title) {
		$this->title = $title;
	}
	
	public function getTitle() {
		return $this->title;
	}
	
	public function setDescription($description) {
		$this->description = $description;
	}
	
	public function getDescription() {
		return $this->description;
	}
	
	public function setKeywords($keywords) {
		$this->keywords = $keywords;
	}
	
	public function getKeywords() {
		return $this->keywords;
	}
	
	public function addLink($href, $rel) {
		$this->links[md5($href)] = array(
			'href' => $href,
			'rel'  => $rel
		);			
	}
	
	public function getLinks() {
		return $this->links;
	}	
	
	public function addStyle($href, $rel = 'stylesheet', $media = 'screen') {
		$this->styles[md5($href)] = array(
			'href'  => $href,
			'rel'   => $rel,
			'media' => $media
		);
	}
	
	public function addSubmenu($name, $href, $attribute = '') {
		$this->submenu[md5($name)] = array(
			'name'		=> $name,
			'href'		=> $href,
			'attribute'	=> $attribute
		);
	}
	
	public function getSubmenu() {
		return $this->submenu;
	}
	
	public function setCurPage($page) {
		if ( in_array($page, $this->page_array) ) {
			$this->current_page = $page;
		}
	}
	
	public function getCurPage() {
		$result = array_fill_keys($this->page_array, '');
		$result[$this->current_page] = ' class="current"';
		
		return $result;
	}
	//用户中心
	public function setCurPageUser($page) {
		if ( in_array($page, $this->page_user_array) ) {
			$this->current_page_user = $page;
		}
	}
	
	public function getCurPageUser() {
		$result = array_fill_keys($this->page_user_array, '');
		$result[$this->current_page_user] = ' class="cur"';
	
		return $result;
	}
	//商家
	public function setCurPageBusiness($page) {
		if ( in_array($page, $this->page_business_array) ) {
			$this->current_page_business = $page;
		}
	}
	
	public function getCurPageBusiness() {
		$result = array_fill_keys($this->page_business_array, '');
		$result[$this->current_page_business] = ' class="cur1"';
	
		return $result;
	}
	public function setRedirectUrl($url) {
		$this->redirect_url = $url;
	}
	
	public function getRedirectUrl() {
		return $this->redirect_url;
	}
	
	public function getStyles() {
		return $this->styles;
	}	
	
	public function addScript($script) {
		$this->scripts[md5($script)] = $script;			
	}
	
	public function getScripts() {
		return $this->scripts;
	}
}
?>